package com.seanLab.dto;

import java.io.Serializable;
import java.text.DecimalFormat;

/**
 * Created by ailly on 17-10-30.
 */
public class MetricsDto implements Serializable {

    private long emptyResultNum;
    private long nonEmptyResultNum;
    private long queryNum;
    private long acceptNum;
    private double coverage;
    private double acceptRate;
    private long top1AcceptNum;
    private long top5AcceptNum;
    private double top1AcceptRate;
    private double top5AcceptRate;

    public MetricsDto(long emptyResultNum, long nonEmptyResultNum,  long acceptNum, long top1AcceptNum, long top5AcceptNum) {
        this.emptyResultNum = emptyResultNum;
        this.nonEmptyResultNum = nonEmptyResultNum;
        this.acceptNum = acceptNum;
        this.top1AcceptNum = top1AcceptNum;
        this.top5AcceptNum = top5AcceptNum;
        this.queryNum = nonEmptyResultNum + emptyResultNum;

        DecimalFormat df = new DecimalFormat( "0.000");

        if (queryNum != 0 && nonEmptyResultNum != 0) {
            top1AcceptRate = Double.parseDouble(df.format( (double)top1AcceptNum / (double)queryNum ));
            top5AcceptRate = Double.parseDouble(df.format( (double)top5AcceptNum / (double)queryNum ));
            coverage = Double.parseDouble(df.format( (double)nonEmptyResultNum / (double)queryNum ));
            acceptRate = Double.parseDouble(df.format( (double)acceptNum / (double)nonEmptyResultNum ));
        } else {
            top1AcceptRate = -1;
            top5AcceptRate = -1;
            coverage = -1;
            acceptRate = -1;
        }

    }

    public MetricsDto() {
    }

    public long getEmptyResultNum() {
        return emptyResultNum;
    }

    public void setEmptyResultNum(long emptyResultNum) {
        this.emptyResultNum = emptyResultNum;
    }

    public long getNonEmptyResultNum() {
        return nonEmptyResultNum;
    }

    public void setNonEmptyResultNum(long nonEmptyResultNum) {
        this.nonEmptyResultNum = nonEmptyResultNum;
    }

    public long getQueryNum() {
        return queryNum;
    }

    public void setQueryNum(long queryNum) {
        this.queryNum = queryNum;
    }

    public long getAcceptNum() {
        return acceptNum;
    }

    public void setAcceptNum(long acceptNum) {
        this.acceptNum = acceptNum;
    }

    public double getCoverage() {
        return coverage;
    }

    public void setCoverage(double coverage) {
        this.coverage = coverage;
    }

    public double getAcceptRate() {
        return acceptRate;
    }

    public void setAcceptRate(double acceptRate) {
        this.acceptRate = acceptRate;
    }

    public long getTop1AcceptNum() {
        return top1AcceptNum;
    }

    public void setTop1AcceptNum(long top1AcceptNum) {
        this.top1AcceptNum = top1AcceptNum;
    }

    public long getTop5AcceptNum() {
        return top5AcceptNum;
    }

    public void setTop5AcceptNum(long top5AcceptNum) {
        this.top5AcceptNum = top5AcceptNum;
    }

    public double getTop1AcceptRate() {
        return top1AcceptRate;
    }

    public void setTop1AcceptRate(double top1AcceptRate) {
        this.top1AcceptRate = top1AcceptRate;
    }

    public double getTop5AcceptRate() {
        return top5AcceptRate;
    }

    public void setTop5AcceptRate(double top5AcceptRate) {
        this.top5AcceptRate = top5AcceptRate;
    }
}
